﻿@model Wicresoft.SelfService.DAO.ClassifyConfig
@{
    ViewBag.Title = "分类维护_" + Model.ServiceName;
    Layout = null;
}

<style type="text/css">
 .hidden
 {
     display:none;
 }
</style>

<script type="text/javascript">
    


    $(function () {
         var partialName='@Model.PartialName';
         if(partialName=='AppSystem'){
            $("tr:gt(0)").attr("class","hidden");
         }

        $("#saveBtn").click(function () 
        {
            var ServiceName = $("#ServiceName").val();
            var check = false;
            if (ServiceName != "") {
                check = true;
            }
            else
            {
                alert("服务名称不能为空！");
                check = false;
            }

            if (check) {
               $.post("@Url.Action("UpdateClassify", "ServiceMaintain")", $("#classifyForm").serialize(), 
               function(data){           
                if(data == "true"){
                    alert("保存成功");
                    location.reload(); 
                }
                else{
                    alert("保存失败")
                }
               });
           }
        });

        $("#deleteBtn").click(function(){
           $.post("@Url.Action("DeleteClassify", "ServiceMaintain")", $("#classifyForm").serialize(), 
           function(data){           
            if(data == "true"){
                alert("删除成功");
                location.reload(); 
            }
            else{
                alert("删除失败")
            }
           })
        });


        $("#Tier1").change(function(){
            var tv1=$("#Tier1").val();
            var tn1=$("#Tier1").find("option:selected").val();
            if(tv1!="0")
            {
                $.ajax({
                    url: "../ServiceMaintain/GetTier2List",
                    type: "GET",
                    data: { "tier1": tn1 },
                    success: function (data) {
                        $("#Tier2").empty();
                        //$("#Tier2").append("<option value=" + 0 + ">" + "--------- 请选择 --------" + "</option>");
                        $.each(data, function (i, item) {
                            //var n = i + 1;
                            $("#Tier2").append("<option>" + item.valueOf(i) + "</option>");
                        });
                    }
                });

            }
        });

        $("#Tier2").change(function(){
            var tv1=$("#Tier1").val();
            var tn1=$("#Tier1").find("option:selected").val();
            var tv2=$("#Tier2").val();
            var tn2=$("#Tier2").find("option:selected").val();
            if(tv2!="0" )
            {
                $.ajax({
                    url: "../ServiceMaintain/GetTier3List",
                    type: "GET",
                    data: { "tier1": tn1,"tier2": tn2 },
                    success: function (data) {
                        $("#Tier3").empty();
                        //$("#Tier3").append("<option value=" + 0 + ">" + "--------- 请选择 --------" + "</option>");
                        $.each(data, function (i, item) {
                            //var n = i + 1;
                            $("#Tier3").append("<option>" + item.valueOf(i) + "</option>");
                        });
                    }
                });
            }
        });

    })

</script>

<div class="right_title">服务分类维护</div>
<div class="right_box_top ui-icons">
</div>
<div class="right_box_bg">
    <div class="right_box">
         <div style="padding-bottom: 20px;">
            @using (Html.BeginForm("UpdateClassify", "ServiceMaintain", FormMethod.Post, new { @id = "classifyForm" }))
            {
                @Html.HiddenFor(model => model.CP)
                @Html.HiddenFor(model => model.ServiceID)
                @Html.HiddenFor(model => model.Isevent)
                @Html.HiddenFor(model => model.Needapprove)
                @Html.HiddenFor(model => model.PartialName)
                @Html.HiddenFor(model => model.ID)
                <table>
                    <tr align="left">
                        <th style="width: 40%;">
                            <label>选择分类:</label>
                        </th>
                        <td>@Html.EditorFor(model => model.ServiceName, new { id = "ServiceName" })</td>
                    </tr>
                    @{
                       if (Model.Isevent == 1)
                       {
                           <tr align="left">
                                <th style="width: 40%;">
                                    <label>事件分类(一):</label>
                                </th>
                                <td>
                                   @Html.DropDownListFor(m => Model.Applvl1, ViewData["Tier1"] as SelectList, new { id="Tier1"})
                                </td>
                            </tr>
                            <tr align="left">
                                <th style="width: 40%;">
                                    <label>事件分类(二):</label>
                                </th>
                                <td>
                                    @Html.DropDownListFor(m => Model.Applvl2, ViewData["Tier2"] as SelectList, new { id = "Tier2" })
                                </td>
                            </tr>
                            <tr align="left">
                                <th style="width: 40%;">
                                    <label>事件分类(三):</label>
                                </th>
                                <td>
                                    @Html.DropDownListFor(m => Model.Applvl3, ViewData["Tier3"] as SelectList, new { id = "Tier3" })
                                </td>
                            </tr>
                            
                       }
                       @*else
                       {
                            <tr align="left">
                                <th style="width: 40%;">
                                    <label>事件分类(一):</label>
                                </th>
                                <td>@Html.EditorFor(model => model.Applvl1, new { id = "Applvl1" })</td>
                            </tr>
                            <tr align="left">
                                <th style="width: 40%;">
                                    <label>事件分类(二):</label>
                                </th>
                                <td>@Html.EditorFor(model => model.Applvl2, new { id = "Applvl2" })</td>
                            </tr>
                            <tr align="left">
                                <th style="width: 40%;">
                                    <label>事件分类(三):</label>
                                </th>
                                <td>@Html.EditorFor(model => model.Applvl3, new { id = "Applvl3" })</td>
                            </tr>
                       }*@
                        
                    }
                    
                </table>
                <input class="Button1 ui-icons" type="button" id="saveBtn" value="保存" style="margin-left: 45px; margin-top: 20px;" />
                @*<input class="Button1 ui-icons" type="button" id="deleteBtn" value="删除" style="margin-left: 45px; margin-top: 20px;" />*@
            }
        </div>
    </div>
</div>
<div class="right_box_down ui-icons">
</div>
